<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Offerbanners extends CI_Controller {

	public function __construct(){
		parent::__construct();

		// load helper
		$this->load->helper('url');
		$this->load->library('session');

		/* load model */
		$this->load->model("Authentication", '', TRUE);
		$this->load->model("Member", '', TRUE);
		$this->load->model("Network", '', TRUE);
		$this->load->model("Offer", '', TRUE);
	}	

	public function index(){
		
		if (!$this->Authentication->IsAuthenticated_Session()){
			redirect('/members/login');
		}
		
		$data['banners'] = $this->Network->getNetworksByType(BANNER);

		$data['mainView'] = 'index';
        $data['controllerName'] = 'offerbanners';
        $this->load->view('layouts/layout', $data);
	}


	public function cpagrip(){

		if (!$this->Authentication->IsAuthenticated_Session()){
			redirect('/members/login');
		}

		$data['banner'] = $this->Network->getBanner(CPAGRIP);

		$data['mainView'] = 'cpagrip';
        $data['controllerName'] = 'offerbanners';
        $this->load->view('layouts/layout', $data);		
	}

	public function banner($networkId){
		
		if (!$this->Authentication->IsAuthenticated_Session()){
			redirect('/members/login');
		}
		
		$data['banner'] = $this->Network->getBanner($networkId);
		$data['offers'] = $this->Offer->getOffersByIP($networkId);

		$data['username'] = $this->session->userdata('username');

		$data['mainView'] = 'banner';
        $data['controllerName'] = 'offerbanners';
        $this->load->view('layouts/layout', $data);
	}
}// end class